<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="content" tagdir="/WEB-INF/tags/content"%>
<title><fmt:message key="advertisementList.title" /></title>

<content tag="buttons">
	<probiz:iconBtn btnType="add" onclick="return fnDoAdd(this)" />
	<probiz:iconBtn btnType="save" onclick="return multiSave(this);" />
	<probiz:iconBtn btnType="delete" onclick="return fnDoMultiDelete(this);" />
</content>

<search:searchBox formAction="${ctxPath}/content/advertisement.html" enableMoreSearch="true">
	<div class="basic_search">
		<search:basicSearch attrPath="s.advertisementName" attrNameKey="advertisement.advertisementName" datatype="String"	operator="LIKE" classes="inputtxt" labelWidth="68px"/>
	</div>
	<div class="more_search">
		<table border="0" cellspacing="0" cellpadding="0" class="search_table">
			<search:input attrPath="s.adPositionType.positionName" attrNameKey="adPositionType.positionName" datatype="String" operator="LIKE" classes="inputtxt" style="width:150px" labelWidth="68px"/>
			<tr>
				<c:set var="contentType">COL@s.contentType@Short@EQ</c:set>
				<c:set var="contentTypeValue">${sc==null?requestScope[contentType]:sc.param[contentType]}</c:set>
				<th><fmt:message key="advertisement.contentType"/><fmt:message key="common.message.colon"/></th>
				<td>
					<select name="${contentType}" id="contentType" class="selecttxt" style="width:150px">
						<option value="" ${(empty contentTypeValue)?'selected':''}><fmt:message key="advertisement.contentType.all"/></option>
						<option value="1" ${(not empty contentTypeValue and contentTypeValue == 1)?'selected':''}><fmt:message key="advertisement.contentType.1"/></option>
						<option value="2" ${(not empty contentTypeValue and contentTypeValue == 2)?'selected':''}><fmt:message key="advertisement.contentType.2"/></option>
					</select>
				</td>
			</tr>
			<tr>
				<c:set var="status">COL@s.status@Short@EQ</c:set>
				<c:set var="statusValue">${sc==null?requestScope[status]:sc.param[status]}</c:set>
				<th><fmt:message key="advertisement.status"/><fmt:message key="common.message.colon"/></th>
				<td>
					<select name="${status}" id="status" class="selecttxt" style="width:150px">
						<option value="" ${(empty statusValue)?'selected':''}><fmt:message key="advertisement.status.all"/></option>
						<option value="1" ${(not empty statusValue and statusValue == 1)?'selected':''}><fmt:message key="advertisement.status.1"/></option>
						<option value="2" ${(not empty statusValue and statusValue == 2)?'selected':''}><fmt:message key="advertisement.status.2"/></option>
						<option value="3" ${(not empty statusValue and statusValue == 3)?'selected':''}><fmt:message key="advertisement.status.3"/></option>
					</select>
				</td>
			</tr>
		</table>
	</div>
</search:searchBox>

<form class="mainForm" name="advertisementListFrm" id="advertisementListForm" method="post"	onsubmit="return validateFormWithMsg(this)">
	<div class="top clearfix">
		<ul class="tab">
			<li class="curr">
				<span><fmt:message key="advertisementList.title" />
				</span>
			</li>
		</ul>
		<%@include file="/common/pagingOnlyTop.jsp"%>
	</div>
	<div class="data">
		<table id="advertisement" width="100%" border="0" cellspacing="0" cellpadding="0" class="list_table" >	
			<tr>
			  	<th width="20"><input onclick="checkAll(this.form)" name="allbox" type="checkbox" value="" /></th>	
				<th style="width:5%">
					<span class="expand" onclick="toggleScreenAll(this)" ></span>
					<span><fmt:message	key="advertisement.view" /></span>
				</th>
				<th class='sortable ${(sc.param["p-sort"] eq 1)?"sorted order1":((sc.param["p-sort"] eq 2)?"sorted order2":"")}'>	
					<a onclick="sortField(this,1,2)"><fmt:message key="advertisement.advertisementName" /></a>
				</th>
				<th  style="width:12%" class='sortable ${(sc.param["p-sort"] eq 9)?"sorted order1":((sc.param["p-sort"] eq 10)?"sorted order2":"")}'>	
					<a onclick="sortField(this,9,10)"><fmt:message key="adPositionType.positionName" /></a>
				</th>
				<th  style="width:8%" class='sortable ${(sc.param["p-sort"] eq 11)?"sorted order1":((sc.param["p-sort"] eq 12)?"sorted order2":"")}'>	
					<a onclick="sortField(this,11,12)"><fmt:message key="advertisement.contentType" /></a>
				</th>
				<th  style="width:10%" class='sortable ${(sc.param["p-sort"] eq 7)?"sorted order1":((sc.param["p-sort"] eq 8)?"sorted order2":"")}'>	
					<a onclick="sortField(this,7,8)"><fmt:message key="advertisement.sortOrder" /></a>
				</th>
				<th style="width:12%" class='sortable ${(sc.param["p-sort"] eq 3)?"sorted order1":((sc.param["p-sort"] eq 4)?"sorted order2":"")}'>	
					<a onclick="sortField(this,3,4)"><fmt:message key="advertisement.startPublishTime" /></a>
				</th>
				<th  style="width:12%" class='sortable ${(sc.param["p-sort"] eq 5)?"sorted order1":((sc.param["p-sort"] eq 6)?"sorted order2":"")}'>	
					<a onclick="sortField(this,5,6)"><fmt:message key="advertisement.endPublishTime" /></a>
				</th>
				<th  style="width:10%" class='sortable ${(sc.param["p-sort"] eq 13)?"sorted order1":((sc.param["p-sort"] eq 14)?"sorted order2":"")}'>	
					<a onclick="sortField(this,13,14)"><fmt:message key="advertisement.status" /></a>
				</th>
			</tr>
			<c:forEach var="advertisement" items="${advertisementList}" varStatus="status">
				<tr id="tr${advertisement.advertisementId}" advertisementId="${advertisement.advertisementId}" class="${(status.index%2==0)?'even':'odd'}">
					<td>
						<input type="checkbox" id="multiIds_${advertisement.advertisementId}" name="multiIds"	value="${advertisement.advertisementId}" class="checkbox" title="${advertisement.advertisementName}" />
						<input type="hidden"  name="advertisementIds" value="${advertisement.advertisementId}" />
					</td>
					<td>
						<span class="expand toggleScreen" onclick="toggleScreen(this)" ></span>
						<span><fmt:message	key="advertisement.view" /></span>
					</td>
					<td>
						<a href="${ctxPath}/content/advertisement.html?doAction=edit&from=list&advertisementId=${advertisement.advertisementId}">
							${advertisement.advertisementName}
						</a>	
					</td>
					<td>
						${advertisement.adPositionType.positionName}
					</td>
					<td>
						<fmt:message key="advertisement.contentType.${advertisement.contentType}"/> 
					</td>
					<td>
						<input type="text" class="inputtxt" size="8" name="sortOrders" id="sortOrder_${advertisement.advertisementId}" value="${advertisement.sortOrder}" />
					</td>
					<td>
						<common:datetimeFormat date="${advertisement.startPublishTime}" />
					</td>
					<td>
						<common:datetimeFormat date="${advertisement.endPublishTime}" />
					</td>
					<td>
						<fmt:message key="advertisement.status.${advertisement.status}" />
					</td>
				</tr>
				<tr style="display: none;" class="${(status.index%2==0)?'even':'odd'} sub" >
					<td></td>
					<td colspan="8">
						<c:choose>
							<c:when test="${advertisement.contentType==2}">
								<OBJECT height=90 width=550 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>
									<PARAM NAME="_cx" VALUE="14552">
									<PARAM NAME="_cy" VALUE="2381">
									<PARAM NAME="FlashVars" VALUE="">
									<PARAM NAME="Movie" VALUE="${mediaPath}${advertisement.url}">
									<PARAM NAME="Src" VALUE="${mediaPath}${advertisement.url}">
									<PARAM NAME="WMode" VALUE="Window">
									<PARAM NAME="Play" VALUE="-1">
									<PARAM NAME="Loop" VALUE="-1">
									<PARAM NAME="Quality" VALUE="High">
									<PARAM NAME="SAlign" VALUE="">
									<PARAM NAME="Menu" VALUE="-1">
									<PARAM NAME="Base" VALUE="">
									<PARAM NAME="AllowScriptAccess" VALUE="">
									<PARAM NAME="Scale" VALUE="ShowAll">
									<PARAM NAME="DeviceFont" VALUE="0">
									<PARAM NAME="EmbedMovie" VALUE="0">
									<PARAM NAME="BGColor" VALUE="">
									<PARAM NAME="SWRemote" VALUE="">
									<PARAM NAME="MovieData" VALUE="">
									<PARAM NAME="SeamlessTabbing" VALUE="1">
									<PARAM NAME="Profile" VALUE="0">
									<PARAM NAME="ProfileAddress" VALUE="">
									<PARAM NAME="ProfilePort" VALUE="0">
									<EMBED src="${mediaPath}${advertisement.url}" WIDTH=${advertisement.width
									}
										HEIGHT=${advertisement.height
									} TYPE="application/x-shockwave-flash"
										PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
									</EMBED>
								</OBJECT>
							</c:when>
							<c:otherwise>
								<img src="${mediaPath}${advertisement.url}" />
							</c:otherwise>
						</c:choose>
					</td>
				</tr>	
			</c:forEach>
			<c:if test="${empty advertisementList}">
				<tr>
					<td colspan="7" style="text-align:center">
						<fmt:message key="advertisementList.empty"/>
					</td>
				</tr>
			</c:if>
		</table>	
		<%@include file="/common/pagingOnly.jsp"%>
	</div>

</form>


<script type="text/javascript">
$j(document).ready(function () {
	$j('input[name="sortOrders"]').each(function(){
		applyValidate(this,"required,integer");
	});
	highlightTableRows("advertisement");
});

//对已有结果进行排序,ascValue表示升序时对应的值,descValue表示降序时对应的值
function sortField(linkDOM,ascValue,descValue){
	var jThDOM = $j(linkDOM).parent('th');
	if(jThDOM.hasClass("order1")){
		location.replace('${ctxPath}/content/advertisement.html?p-sort='+descValue);
	}else{
		location.replace('${ctxPath}/content/advertisement.html?p-sort='+ascValue);
	}
}

//显示 隐藏全部
function toggleScreenAll(linkDOM){
	if($j(linkDOM).hasClass("expand")){
		$j(linkDOM).removeClass("expand").addClass("shrink");
		$j('span.toggleScreen').each(function(){
			var jTrThis = $j(this).parents('tr:first');
			var jTrFull = jTrThis.next();
			jTrFull.show();
			$j(this).removeClass("expand").addClass("shrink");
		});
	
	}else{
		$j(linkDOM).removeClass("shrink").addClass("expand");
		$j('span.toggleScreen').each(function(){
			var jTrThis = $j(this).parents('tr:first');
			var jTrFull = jTrThis.next();
			jTrFull.hide();
			$j(this).removeClass("shrink").addClass("expand");
		});
	}
}	

//显示 隐藏详细
function toggleScreen(linkDOM){
	var jTrThis = $j(linkDOM).parents('tr:first');
	var jTrFull = jTrThis.next();
	if(jTrFull.is(":hidden")){
		jTrFull.show();
		$j(linkDOM).removeClass("expand").addClass("shrink");
	}else{
		jTrFull.hide();
		$j(linkDOM).removeClass("shrink").addClass("expand");
	}
	
}	

function multiSave(){
	  if(!validateForm(document.forms["advertisementListForm"])){
	  	alert(__vaMsg.notPass);
	  	return;
	  }
	  document.forms["advertisementListForm"].action="${ctxPath}/content/advertisement.html?doAction=multiSave"
	  document.forms["advertisementListForm"].method="post"
	  document.forms["advertisementListForm"].submit();
	}
	</script>

</script>

